<?php
function FindDept($db, $uid)
{
    $from_base_user = $db->query("SELECT DepartmentId from Base_User WHERE Account = '$uid'");
    $row_base_user = $from_base_user->fetch();
    $account = $row_base_user['DepartmentId'];
    $from_base_dept = $db->query("SELECT FullName from Base_Department WHERE DepartmentId = '$account'");
    $row_base_department = $from_base_dept->fetch();
    return ($row_base_department['FullName']);
}

function FindName($db, $uid)
{
    $from_base_user = $db->query("SELECT RealName from Base_User WHERE Account = '$uid'");
    $row_base_user = $from_base_user->fetch();
    $name = $row_base_user['RealName'];
    return ($name);
}

function from_dept_find_name($db, $dept_name)
{
    $from = $db->query("SELECT DepartmentId from Base_Department WHERE FullName = '$dept_name'");
    $row = $from->fetch();
    $dept_id = $row['DepartmentId'];
    $name_array = array();
    $i = 0;
    $from = $db->query("SELECT RealName from Base_User WHERE DepartmentId = '$dept_id'");
    while ($row = $from->fetch()) {
        $name_array[$i] = $row['RealName'];
        $i++;
    }
    return ($name_array);
}